import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

import { formatToYuan } from '#/utils/common';

export const querySchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    componentProps: {
      placeholder: '请输入订单号',
    },
    fieldName: 'orderNo',
    label: '订单号',
  },
  {
    component: 'Input',
    componentProps: {
      placeholder: '请输入微信流水号',
    },
    fieldName: 'transactionId',
    label: '微信流水号',
  },
  {
    component: 'RangePicker',
    componentProps: {
      placeholder: ['开始时间', '结束时间'],
    },
    fieldName: 'createTime',
    label: '支付时间',
  },
];

export const columns: VxeGridProps['columns'] = [
  {
    title: '订单ID',
    field: 'orderId',
    width: 100,
  },
  {
    title: '订单号',
    field: 'orderNo',
    width: 250,
  },
  {
    align: 'right',
    title: '订单价格',
    field: 'orderPrice',
    width: 120,
    formatter: ({ cellValue }) => {
      return formatToYuan(cellValue);
    },
  },
  {
    title: '微信流水号',
    field: 'transactionId',
    width: 250,
  },
  {
    title: '通知内容',
    field: 'notifyContent',
    minWidth: 300,
  },
];

/**
 * 订单状态选项(用于导出)
 */
export const orderStatusOptions = [
  {
    label: '待支付',
    value: 1,
  },
  {
    label: '预约中',
    value: 2,
  },
  {
    label: '预约成功',
    value: 3,
  },
  {
    label: '预约失败',
    value: 4,
  },
  {
    label: '已退款',
    value: 5,
  },
  {
    label: '已取消',
    value: 6,
  },
];

export const exportSchema: FormSchemaGetter = () => [
  {
    component: 'Select',
    componentProps: {
      allowClear: true,
      options: orderStatusOptions,
      placeholder: '请选择订单状态',
    },
    fieldName: 'orderStatus',
    label: '订单状态',
  },
  {
    component: 'RangePicker',
    componentProps: {
      placeholder: ['开始时间', '结束时间'],
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      showTime: true,
    },
    fieldName: 'dateRange',
    label: '订单时间',
  },
];
